package controller

import (
	"gitee.com/DonHz/qimi/bluebell/logic"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"strconv"
)

func CommunityHandler(c *gin.Context) {
	// 查询到所有社区（id和name）以列表形式返回
	data, err:=logic.GetCommunityList()
	if err!=nil {
		zap.L().Error("logic.GetCommunityList() failed: ", zap.Error(err))
		ResponseError(c, CodeServerBusy)
		return
	}
	ResponseSuccess(c, data)
}

func CommunityDetailHandler(c *gin.Context) {
	idStr:=c.Param("id")
	Id, err:=strconv.ParseInt(idStr, 10, 64)
	if err!=nil {
		ResponseError(c, CodeInvalidParam)
		return
	}
	// 查询到所有社区（id和name）以列表形式返回
	data, err:=logic.GetCommunityById(Id)
	if err!=nil {
		zap.L().Error("logic.GetCommunityList() failed: ", zap.Error(err))
		ResponseError(c, CodeServerBusy)
		return
	}
	ResponseSuccess(c, data)
}